//
//  AppDelegate.swift
//  Tala
//
//  Created by mini on 2025/4/28.
//

import UIKit
import IQKeyboardManagerSwift

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // 禁用黑暗模式
        if #available(iOS 13.0, *){
            window?.overrideUserInterfaceStyle = .light
        }
        keyboardManagerConfig()
        networkConfig()
        LocationService.shared.startUpdatingLocation()
        
        // createRootNav
        GlobalMethod.createRootNav()
        Thread.sleep(forTimeInterval: 1.0)
        window?.overrideUserInterfaceStyle = .light
        NetworkPermissionManager.requestNetworkPermission()
        
        return true
    }

    // 配置网路请求参数
    func networkConfig() {
        var config = NetworkConfiguration(baseURL: URL(string: URL_HEAD))
        // config.networkInterceptor是对所有网络请求的拦截器，可在拦截器中统一的添加参数，请求头。
        config.networkInterceptor = GlobalInterceptor()
        NetworkManager.default.configuration = config
    }

    // 键盘配置
    func keyboardManagerConfig() {
        IQKeyboardManager.shared.isEnabled = true
        // 当点击键盘外部时，键盘是否应该关闭
        IQKeyboardManager.shared.resignOnTouchOutside = true
    }
}

